#ifndef _packet_h
#define _packet_h

#define HEADER_SIZE 15 // In bytes
#define PADDING_SIZE 8
#define NO_ERR 0
#define LOST_PACK 1
#define LOST_ACK 2
#define CORR_PACK 3

#include "crc.h"

using namespace std;

class Packet {
	private:
		CRC crcProgram;
		int maxPayloadSize;
		int packetSize;
		short payloadSize; // In Header
		unsigned int crc; // In Header
		char* payload;
		char* packet;
		Blowfish* bf;

	public:
		Packet(int, Blowfish*);
		Packet(char*, int, Blowfish*);
		~Packet();

		int clientId; // In Header
		short seqNum; // In Header
		short packetNum; // In Header
		char eof; // In Header
		bool ackRecieved;
		bool sent;
		bool hasReset;
		int errorType;
		timespec timeout;

		void reset();
		void decryptPayload(string);
		char* getPayload();
		void setPayload(char*, int, bool);
		char* buildPacket();
		char* buildAck();
		bool isEof();
		void setEof(bool);
		short getPayloadSize();
		bool checkCrc();
};

#endif

